package com.zmn.brs.admin.controller.ding.group.robot;

import java.util.List;

import com.zmn.brs.model.entity.robot.DingGroupRobot;
import com.zmn.brs.model.entity.robot.DingGroupRobotQuery;
import com.zmn.common.dto2.ResponseDTO;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;


/**
 * 钉钉群机器人
 *
 * @author liuyong
 * @since 2021-08-02 11:41:35
 */
@Controller
@RequestMapping("/ding/group/robot/")
public class DingGroupRobotListController extends DingGroupRobotBaseController {

    /**
     * 列表
     *
     * @param query
     * @author liuyong
     * @since 2021-08-02 11:41:35
     */
    @RequestMapping("list")
    @RequiresPermissions("/ding/group/robot/list.action")
    public ModelAndView list(@ModelAttribute DingGroupRobotQuery query) {

        List<DingGroupRobot> items = dingGroupRobotService.listPageByQuery(query);

        ModelAndView mav = new ModelAndView("ding/group/robot/list");
        mav.addObject("items", items);
        mav.addObject("vo", query);
        return mav;
    }




    /**
     * 详情
     *
     * @param robotId
     * @author liuyong
     * @since 2021-08-02 11:41:35
     */
    @RequestMapping("detail")
    @RequiresPermissions("/ding/group/robot/detail.action")
    public ModelAndView detail(@RequestParam(value = "robotId", defaultValue = "0") Integer robotId) {
        DingGroupRobot brsDingGroupRobot;
        if (robotId == 0) {
            brsDingGroupRobot = new DingGroupRobot();
        } else {
            brsDingGroupRobot = dingGroupRobotService.findById(robotId);
        }
        ModelAndView mav = new ModelAndView("ding/group/robot/detail");
        mav.addObject("obj", brsDingGroupRobot);
        return mav;
    }

}
